package com.richpencil.modules.weixin.domain;

import java.io.UnsupportedEncodingException;

public class GeneralObject {

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public boolean success = false;

    public String getUserid() {
        return fuserid;
    }

    public void setUserid(String userid) {
        this.fuserid = userid;
    }

    public String getVoteid() {
        return factionid;
    }

    public void setVoteid(String voteid) {
        this.factionid = voteid;
    }
    public String getFappid() {
        return fappid;
    }

    public void setFappid(String fappid) {
        this.fappid = fappid;
    }
    public String fuserid = "";

    public String getFactionid() {
        return factionid;
    }

    public void setFactionid(String factionid) {
        this.factionid = factionid;
    }

    public String factionid = "";


    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String fappid="";

    public GeneralObject() {

    }

    public Integer state;

    public String getFuserid() {
        return fuserid;
    }

    public void setFuserid(String fuserid) {
        this.fuserid = fuserid;
    }

    public GeneralObject(String identitycode) {
        String[] array = identitycode.split("@");
        if(array.length>0)
        {
            Integer state=Integer.parseInt(array[0]);
            switch (state){
                //病历邀请
                case 1:
                    break;
                //vote
                default:
                    if (array.length == 2) {
                        this.factionid = array[0];
                        this.fuserid = array[1];
                        this.setSuccess(true);
                    } else if (array.length == 1) {
                        this.factionid = array[0];
                        this.fuserid = "";
                        this.setSuccess(true);
                    } else {
                        this.setSuccess(false);
                    }
                    break;
            }
        }



    }

    public static String json(String voteid, String userid) throws UnsupportedEncodingException {
        GeneralObject go = new GeneralObject();
        go.factionid = voteid;
        go.fuserid = userid;
        String jsonstring = go.factionid + "@" + go.fuserid;
        return jsonstring;
    }
}